"""
A no frills function to flatten nested lists or tuples. Taken 
from http://code.activestate.com/recipes/577250-flatten-a-list/?in=user-4174072#c3
"""
# flattens a list eg. flatten(1, 2, ['b','a','c']) = [1, 2, 'a', 'b', 'c']
def flatten(*args):
    x = []
    for l in args:
        if not isinstance(l, (list, tuple)): l = [l]
        for item in l:
            if isinstance(item, (list,tuple)):
                x.extend(flatten(item))
            else:
                x.append(item)
    return x


